public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
    //求最大数组和
    public int maxSubArray(int[] nums) {
        int pre = 0, maxAns = nums[0];
        for (int x : nums) {
            pre = Math.max(pre + x, x);
            maxAns = Math.max(maxAns, pre);
        }
        return maxAns;
    }

    //轮转数组
    public void rotate(int[] nums, int k) {
        k %= nums.length;
        remove(nums,0,nums.length-1);
        remove(nums,0,k-1);
        remove(nums,k,nums.length-1);
    }
    private void remove(int[] nums,int start,int end){
        while(start<end){
            int flag=0;
            flag=nums[start];
            nums[start]=nums[end];
            nums[end]=flag;
            start++;end--;
        }
    }
}